package io.dy.controller;

import io.dy.model.Message;
import io.dy.mq.producer.SafeTopicProducer;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dmj
 * @date 2024年04月18日 下午4:57
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/io/dy/safe")
public class SafeMqController {

    private final SafeTopicProducer safeTopicProducer;


    @PostMapping("/v1")
    public boolean send(@RequestBody Message message){
        return safeTopicProducer.send(message);
    }

    @PostMapping("/v2")
    public boolean sendV2(@RequestBody Message message){
        return safeTopicProducer.sendErrorForExchange(message);
    }

    @PostMapping("/v3")
    public boolean sendV3(@RequestBody Message message){
        return safeTopicProducer.sendErrorForQueue(message);
    }

    @PostMapping("/v4")
    public boolean sendV4(@RequestBody Message message){
        return safeTopicProducer.sendInnerConfirm(message);
    }
}
